package com.xyg.product.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.xyg.common.model.TreeEntity;

import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name="xyg_product_category")
public class Category extends TreeEntity<Category, Long>{

	private String icon;
	
	private Status status;
	
	@ManyToMany(fetch=FetchType.LAZY,mappedBy="cotegories",cascade={CascadeType.REFRESH,CascadeType.PERSIST,CascadeType.REMOVE,CascadeType.MERGE})
	private Set<Brand> brands = new HashSet<>();
	
	@OneToMany(fetch=FetchType.LAZY,mappedBy="category",cascade={CascadeType.REFRESH,CascadeType.PERSIST,CascadeType.REMOVE,CascadeType.MERGE})
	private Set<Property> properties = new HashSet<>();
	
	@OneToMany(fetch=FetchType.LAZY,mappedBy="category",cascade={CascadeType.REFRESH,CascadeType.PERSIST,CascadeType.REMOVE,CascadeType.MERGE})
	private Set<Product> products = new HashSet<>();
	
	public enum Status {
		normal,disable,deleted
	}
	

}
